🧹 Code Health: Refactor duplicated user prompt logic into Confirm-Action function#21
🧹 Code Health: Refactor duplicated user prompt logic into Confirm-Action function#21murilogiatti wants to merge 1 commit into
Conversation
Introduced a `Confirm-Action` function to abstract away the repeated `Read-Host` and conditional check logic. This function accepts a prompt string and a scriptblock to execute if the user confirms. Replaced the three repeated blocks for `chkdsk`, `Microsoft Store`, and `Restart-Computer` with this new function, improving code maintainability. Adjusted Pester tests to mock the fully qualified path for chkdsk. Co-authored-by: murilogiatti <38364583+murilogiatti@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
🎯 What: The code health issue addressed
Refactored duplicated user prompt logic in
CleanupAndUpdateEverything.ps1. Created a reusableConfirm-Actionfunction to handleRead-Hostcalls and execute a scriptblock conditionally based on user input.💡 Why: How this improves maintainability
It reduces code duplication and standardizes how user confirmations and subsequent actions are handled within the script. This makes adding future prompts cleaner and easier to read.
✅ Verification: How you confirmed the change is safe
Ran the full Pester test suite (
CleanupAndUpdateEverything.Tests.ps1) to ensure all assertions around prompts and conditional command execution still pass exactly as they did before the refactoring.✨ Result: The improvement achieved
A cleaner, more maintainable script with a centralized function for handling user confirmation logic.
PR created automatically by Jules for task 12722637397257199351 started by @murilogiatti